<?php 
$this->headLink(array('href' => '/cms/styles/style.css', 'rel' => "stylesheet", 'type' => "text/css"));

$this->headScript(Zend_View_Helper_HeadScript::FILE,'/cms/scripts/dojo/dojo.js');
$this->headScript(Zend_View_Helper_HeadScript::FILE,'/cms/scripts/Popup.js');
$this->headScript(Zend_View_Helper_HeadScript::SCRIPT,<<<EOD
function chooseMenuType(type_id) {
	dojo.query('tr.type_linked')
		.forEach(
			function (item,index,array) {
			
				item.style.display = (item.getAttribute('rel')==type_id ? '' : 'none');
			}
		);
	
	
	
}

EOD
);


$this->layout()->body_attr = 'class="modal" onload="chooseMenuType('.$this->post_data['menu_type_id'].')"';
?>
<form action="" method="post">
  <table class="form" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td class="lablel">&nbsp;</td>
      <td><h1 id="winTitle"><?= $this->title?></h1></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td class="lablel">Название:</td>
      <td><input name="name" type="text" class="modalInput" id="name" value="<?= htmlspecialchars($this->post_data['name']) ?>" style="width:400px" />
<?php 
if (isset($this->errors)) {
	if (isset($this->errors['name'])) {
?>
		<ul class="errors">
		<?php for ($e=0;$e<count($this->errors['name']);$e++) { ?>
			<li><?= $this->errors['name'][$e]?></li>
		<?php } ?>
		</ul>
<?php 		
	}
}
?>
      </td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td class="lablel">Тип:</td>
      <td class="stnd_font" valign="middle">
<?php  for ($t=0;$t<count($this->menu_type_list);$t++) { ?>
        <input onclick="chooseMenuType(this.value)" type="radio" name="menu_type_id" value="<?= $this->menu_type_list[$t][0] ?>" id="menu_type_<?= $this->menu_type_list[$t][0] ?>" <?= $this->post_data['menu_type_id']==$this->menu_type_list[$t][0] ? 'checked="checked"' : '' ?> />
        <label for="menu_type_<?= $this->menu_type_list[$t][0] ?>"><?= $this->menu_type_list[$t][2] ?></label>
<?php } ?>
      
      </td>
      <td>&nbsp;</td>
    </tr>
    <tr class="type_linked" rel="3">
      <td class="lablel">Url:</td>
      <td><input name="direct_url" id="direct_url"  type="text"  class="modalInput"  style="width:400px"  value="<?= htmlspecialchars($this->post_data['direct_url']) ?>" />
<?php 
if (isset($this->errors)) {
	if (isset($this->errors['menu_type_id'])) {
?>
		<ul class="errors">
		<?php for ($e=0;$e<count($this->errors['menu_type_id']);$e++) { ?>
			<li><?= $this->errors['menu_type_id'][$e]?></li>
		<?php } ?>
		</ul>
<?php 		
	}
}
?>
      </td>
      <td>&nbsp;</td>
    </tr>
    <tr class="type_linked" rel="1">
      <td class="lablel">Алиас:</td>
      <td><input name="alias" type="text" class="modalInput" id="alias" style="width:400px" value="<?= htmlspecialchars($this->post_data['alias']) ?>" />
<?php 
if (isset($this->errors)) {
	if (isset($this->errors['alias'])) {
?>
		<ul class="errors">
		<?php for ($e=0;$e<count($this->errors['alias']);$e++) { ?>
			<li><?= $this->errors['alias'][$e]?></li>
		<?php } ?>
		</ul>
<?php 		
	}
}
?>
      </td>
      <td><div style="padding:4px"><img src="/cms/images/splash-hint-16.gif" width="16" height="16" id="aliasHintTrigger" /></div>
        <div class="splashHint" id="aliasSplashHint" style="width:200px">Поле Алиас необязательно для заполнения, но алиас должен быть уникальным, т.к. если заполнено, используется в URL-адресе, как текстовый идентификатор страницы</div>
        <script type="text/javascript">new PopupArea('aliasHintTrigger','aliasSplashHint',PopupAreaAdaptors.mouseOverSplashUnderTrigger);</script></td>
    </tr>
    <tr class="type_linked" rel="1">
      <td class="lablel">Шаблон:</td>
      <td><select name="template" id="template" class="modalInput" style="width:400px">
<?php for ($t=0;$t<count($this->template_list);$t++) { ?>
        <option value="<?= $this->template_list[$t]['key'] ?>"<?= $this->current_template==$this->template_list[$t]['key'] ? ' selected="selected"' : '' ?>><?= $this->template_list[$t]['value'] ?></option>
<?php } ?>
      </select>
<?php 
if (isset($this->errors)) {
	if (isset($this->errors['template'])) {
?>
		<ul class="errors">
		<?php for ($e=0;$e<count($this->errors['template']);$e++) { ?>
			<li><?= $this->errors['template'][$e]?></li>
		<?php } ?>
		</ul>
<?php 		
	}
}
?>
      </td>
      <td><?php if ($this->template_alert) { ?><div style="padding:4px"><img src="/cms/images/exclamination.gif" width="16" height="16" id="templateHintTrigger" /></div>
        <div class="splashHint" id="templateSplashHint" style="width:200px">Внимание! Изменение шаблона для раздела вызовет удаление всех данных.</div>
        <script type="text/javascript">new PopupArea('templateHintTrigger','templateSplashHint',PopupAreaAdaptors.mouseOverSplashUnderTrigger);</script><?php } ?></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" class="okButton" id="okButton" value="Сохранить" />
          <input type="button" class="okButton" value="Отмена" onclick="window.parent.setTimeout('Shadowbox.close()',10)" /></td>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>